My engine is a static lib and my Makefile for win32-gcc creates a dll (that works!). Even though it works I don't want that dll so how can I make it only a static lib?
Makefile:
Code: Select all
VERSION = 0.1
# make
# This will compile NGE, create a static lib (libNGE.a), and copy it into the subdirectory lib/Linux. That's all.
# If you want NGE to be compiled as shared lib (libNGE.so.versionnumber), then run:
# make sharedlib
# make install
#List of object files
NGEOBJ = CConfigManager.o CursorController.o FontController.o Game.o GameEntity.o GameManager.o GameState.o GridSceneNode.o CIniFileReaderIrr.o CIniFileReaderStub.o CIrrKlangDevice.o CIrrKlangPlayedSound.o CIrrKlangSoundObj.o NGEReceiver.o NUSoftwareIntroSceneNode.o StateCredits.o StateIntro.o StateMenu.o StatePlay.o StateSettings.o IAudioDevice.o IConfigManager.o IIniFileReader.o nge.o NUS.o CLevelManager.o CEmptyLevelNode.o CRegionLevelNode.o CWorldLevelNode.o CZoneGroupLevelNode.o CZoneLevelNode.o Level.o NUSoftwareIntroLevel.o CNullAudioDevice.o CNullPlayedSound.o CNullSoundObj.o ISoundEmitterSceneNode.o ISoundListenerSceneNode.o CSceneNodeControllerAnimator.o IActor.o INPC.o IPlayer.o PlayerSpaceship.o IItemEntity.o
# Next variable is for additional scene nodes etc. of customized NGE versions
EXTRAOBJ =
LINKOBJ := $(NGEOBJ) $(EXTRAOBJ)
###############
#Compiler flags
CXXINCS = -I../include -IIrrlicht -IirrKlang
CPPFLAGS = $(CXXINCS) -DIRRLICHT_EXPORTS=1
CXXFLAGS = -Wall
ifndef NDEBUG
CXXFLAGS += -g -D_DEBUG
else
CXXFLAGS += -fexpensive-optimizations -O3
endif
ifdef PROFILE
CXXFLAGS += -pg
endif
CFLAGS := -fexpensive-optimizations -O3 -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES
#Linux specific options
STATIC_LIB = libNGE.a
SHARED_LIB = libNGE.so
NGE_DLL := ../bin/Win32-gcc/NGE.dll
LIB_PATH = ../lib/$(SYSTEM)
INSTALL_DIR = /usr/local/lib
staticlib sharedlib install: SYSTEM = Linux
staticlib sharedlib : LDFLAGS = --no-export-all-symbols --add-stdcall-alias
sharedlib : LDFLAGS += -L/usr/X11R6/lib -lGL -lXxf86vm -L../lib/Linux ../lib/Linux/libIrrKlang.so
staticlib sharedlib : CXXINCS += -I/usr/X11R6/include
#Windows specific options
sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc
sharedlib_win32: LDFLAGS = -lgdi32 -L../lib/Win32-gcc -lirrlicht -lirrKlang
sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL
staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
####################
# All target, builds NGE as static lib (libNGE.a) and copies it into /lib/Linux
all linux: staticlib
# Builds NGE as shared lib (libNGE.so.versionNumber) and copies it into /lib/Linux
sharedlib: $(LINKOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -Wl,-soname,$(SHARED_LIB).1 -fPIC -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS)
cp $(SHARED_LIB).$(VERSION) $(LIB_PATH)
# Builds NGE as static lib (libNGE.a)
$(STATIC_LIB): $(LINKOBJ)
$(AR) rs $@ $^
# Copies static lib into /lib/Linux
staticlib: $(STATIC_LIB)
cp $^ $(LIB_PATH)
# Builds NGE as dll (NGE.dll) into ../bin/Win32-gcc
all_win32 win32: sharedlib_win32
sharedlib_win32: $(NGE_DLL)
../bin/Win32-gcc/NGE.dll: $(LINKOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -o $@ $^ $(LDFLAGS) -Wl,--out-implib,../lib/Win32-gcc/$(STATIC_LIB)
# Copies static lib into /lib/Win32-gcc
staticlib_win32: $(STATIC_LIB)
cp $^ $(LIB_PATH)
# Installs NGE if it was created as shared lib
install:
cp $(LIB_PATH)/$(SHARED_LIB).$(VERSION) $(INSTALL_DIR)
cd $(INSTALL_DIR) && ln -s libNGE.so.$(VERSION) $(SHARED_LIB)
ldconfig -n $(INSTALL_DIR)
# Create dependency files for automatic recompilation
%.d:%.cpp
$(CXX) $(CPPFLAGS) -MM -MF $@ $<
-include $(LINKOBJ:.o=.d)
help:
@echo "Available targets for NGE"
@echo " sharedlib: Build shared library NGE.so for Linux"
@echo " staticlib: Build static library NGE.a for Linux"
@echo " install: Copy shared library to /usr/lib"
@echo ""
@echo " sharedlib_win32: Build shared library NGE.dll for Windows"
@echo " staticlib_win32: Build static library NGE.a for Windows"
@echo ""
@echo " clean: Clean up directory"
# Cleans all temporary files and compilation results.
clean:
$(RM) $(LINKOBJ) $(SHARED_LIB).$(VERSION) $(STATIC_LIB) $(LINKOBJ:.o=.d)
.PHONY: all sharedlib staticlib sharedlib_win32 staticlib_win32 help install clean
P.S
randomMesh created that Makefile.