Compile C++ Code On Linux Using Makefile
This makefile shows examples of different flags like CC, -Wall, ffast-math, -Werror, static, shared, @strip, .so . It also shows examples of Sources & Targets.
# Makefile for the X-Series-so # Compilers (C and C++) CC=gcc34 CXX=g++34 LIB-NAME=libXSeries #CFLAGS =-Wall -Werror -ffast-math -I/opt/pif-x86/usr/include -DPIF_ON_GAMES CFLAGS =-Wall -Werror -ffast-math -DICORE_ON_GAMES OBJECTS= api.o apiutil.o hwinfo.o xsocket.o apievents.o apicmd.o xthread.o efxevent.o readcfg.o initenum.o language.o heartbeatthread.o arrayqueue.o gethset.o usb.o memusage.o mount.o # pif.o all: $(OBJECTS) shared shared-strip CPLIB eX2_3D_lib PROG CPTEST #clean $(OBJECTS): %.o:src/%.cpp #src/include/%.h $(CXX) $(CFLAGS) -c $< static: @ar rsc ${LIB-NAME}.a $(OBJECTS) shared: $(CXX) $(CFLAGS) -Wl,-soname,${LIB-NAME}.so -fpic -shared -o ${LIB-NAME}.so $(OBJECTS) -lc shared-strip: shared @strip ${LIB-NAME}.so CPLIB: @cp ${LIB-NAME}.so lib/. @cp ${LIB-NAME}.so eFX-fbcon-lib/. @cp ${LIB-NAME}.so PCLinux/. @cp ${LIB-NAME}.so PCLinux-3D/. eX2_3D_lib: @cp ${LIB-NAME}.so eX2-3D-lib/. clean: @rm -f *.o *.so ${LIB-NAME}.so ${LIB-NAME}.a ${NAME} ${PCNAME} *~ src/*.cpp~ src/api-include/*.h~ CFLAGSTEST =-Wall -g -O3 -ffast-math -Wno-deprecated $(shell sdl-config --cflags) SDL_LDFLAGS := # $(shell sdl-config --libs) -lSDL_image -lSDL_mixer #UTILLIBS= -lrt -L /opt/pif-x86/usr/lib -lpif -L lib -lSDL -lSDL_image -lSDL_mixer -lUtil -lXSeries UTILLIBS=-L lib -lSDL -lSDL_image -lSDL_mixer -lUtil -lXSeries TEST-OBJECTS=test.o NAME=XSeriesTest.out PCNAME=PC.out PROG: $(TEST-OBJECTS) $(CXX) $(SDL_LDFLAGS) -s -o $(NAME) $(TEST-OBJECTS) $(UTILLIBS) $(TEST-OBJECTS): %.o: src/%.cpp $(CXX) -c $(CFLAGSTEST) $< -o $@ CPTEST: @cp ${NAME} ${PCNAME}