Created
December 12, 2011 03:57
-
-
Save rdeguzman/1464734 to your computer and use it in GitHub Desktop.
Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PROG = ncm | |
| INCDIR = include libsai | |
| BUILDDIR = build | |
| LIBSAI = libSAI.a | |
| DEPENDS = .depend | |
| HOST := $(shell hostname) | |
| USER := $(shell id -un) | |
| UNAME := $(shell uname -s) | |
| BUILDHOST := -DBUILDHOST=\"$(HOST)\" | |
| BUILDUSER := -DBUILDUSER=\"$(USER)\" | |
| INSTALLDIR = dist/bin | |
| ifeq ($(UNAME),Darwin) | |
| INCDIR += /usr/local/include | |
| INCDIR += /usr/local/libxml++1.0/include/libxml++-1.0 | |
| #INCDIR += /usr/local/include/libxml++-2.6 | |
| #INCDIR += /usr/local/include/glibmm-2.4 | |
| LIBS += -L/usr/local/lib | |
| else | |
| PGSQLBASE = /usr/local | |
| INCDIR += /usr/local/include/libxml++-1.0/ | |
| INCDIR += $(PGSQLBASE)/include | |
| LIBS += -L$(PGSQLBASE)/lib | |
| endif | |
| #LIBS += -lpq -lcrypto -lxml++-1.0 | |
| LIBS += -lpq -lcrypto | |
| VPATH = $(BUILDDIR):src:libsai | |
| PSRC = main.cpp Log.cpp stringops.cpp WatchDog.cpp \ | |
| ioBuffer.cpp iBuffer.cpp oBuffer.cpp Connection.cpp \ | |
| NCMConnection.cpp QMsg.cpp GPSReport.cpp AM.cpp AMop.cpp hash_64.c \ | |
| DI.cpp DI_GPS.cpp DI_Session.cpp DI_DBInfo.cpp DI_Keys.cpp \ | |
| DI_SendQueue.cpp DI_Config.cpp DI_Mapper.cpp \ | |
| DI_Questionaire.cpp DI_Geofence.cpp DI_MCCMove.cpp DI_MCCVersion.cpp\ | |
| AKH.cpp Authkey.cpp AuthkeyDES3.cpp\ | |
| EC.cpp EC_AM.cpp EC_SAI.cpp Routemap.cpp Channel.cpp | |
| SSRC = SAI.cpp SAI_Acl.cpp SAI_ChanRoute.cpp SAI_Channel.cpp \ | |
| SAI_Control.cpp SAI_Forward.cpp SAI_Mapper.cpp SAI_MapperSM.cpp SAI_MapperMSM.cpp \ | |
| SAI_Notify.cpp SAI_Ping.cpp SAI_Reg.cpp \ | |
| SAI_RegMgr.cpp SAI_Relay.cpp SAI_Response.cpp \ | |
| SAI_Route.cpp SAI_Src.cpp SAI_Sys.cpp SAI_Time.cpp \ | |
| SAI_Config.cpp SAI_SendQueue.cpp SAI_SMT.cpp \ | |
| SAI_Questionaire.cpp SAI_Geofence.cpp SAI_MCCMove.cpp \ | |
| SAI_MCCVersion.cpp | |
| ALLSRC = $(PSRC) $(SSRC) | |
| PSRCS = $(addprefix src/,$(PSRC)) | |
| POBJS = $(addsuffix .o,$(basename $(PSRC))) | |
| SSRCS = $(addprefix libsai/,$(SSRC)) | |
| SOBJS = $(addsuffix .o,$(basename $(SSRC))) | |
| ALLSRCS = $(PSRCS) $(SSRCS) | |
| $(foreach dir,$(dirs),$(wildcard $(dir)/*)) | |
| INCLUDES= $(foreach dir,$(INCDIR),-I$(dir)) | |
| # Cannot use -ansi here, since long long is not ANSI supported | |
| WARNALL = -W -Wall -Wcast-align -Wcast-qual -Wchar-subscripts\ | |
| -Wmissing-prototypes -Wpointer-arith -Wredundant-decls\ | |
| -Wstrict-prototypes -Wwrite-strings | |
| WARNLVL = -W -Wall | |
| OPTLVL = -O | |
| OPTDBG = -g -fno-inline | |
| CPPFLAGS+= -DUNAME=\"$(UNAME)\" # -D_AMDEBUG=1 | |
| CXXFLAGS+= -arch i386 $(OPTLVL) $(OPTDBG) $(WARNLVL) $(INCLUDES) | |
| CFLAGS+= -arch i386 $(OPTLVL) $(OPTDBG) $(WARNLVL) $(INCLUDES) | |
| VSRC := version.cpp | |
| VOBJ := version.o | |
| RANLIB ?= ranlib | |
| INSTALL ?= install | |
| RM ?= rm -f | |
| LN ?= ln -s | |
| # TARGETS | |
| all: $(PROG) | |
| $(LIBSAI): $(SOBJS) | |
| @echo Building static library: $(LIBSAI) | |
| @$(RM) $(LIBSAI) | |
| ifeq ($(UNAME),FreeBSD) | |
| @$(AR) cq $(LIBSAI) `lorder $(addprefix $(BUILDDIR)/,$(SOBJS)) | tsort -q` | |
| @$(RANLIB) $(LIBSAI) | |
| else | |
| @$(AR) cqs $(LIBSAI) $(addprefix $(BUILDDIR)/,$(SOBJS)) | |
| endif | |
| %.o: %.cpp $(BUILDDIR) | |
| $(CXX) $(CXXFLAGS) -c $< -o $(BUILDDIR)/$@ | |
| %.o: %.c $(BUILDDIR) | |
| $(CC) $(CFLAGS) -c $< -o $(BUILDDIR)/$@ | |
| $(PROG): $(LIBSAI) $(POBJS) | |
| @echo Linking $(PROG) `scripts/buildnumber.pl $(VSRC)` | |
| @$(CXX) $(BUILDHOST) $(BUILDUSER) $(CXXFLAGS) -c $(VSRC) -o $(BUILDDIR)/$(VOBJ) | |
| $(CXX) $(OPTDBG) -o $(PROG) $(addprefix $(BUILDDIR)/,$(POBJS)) $(BUILDDIR)/$(VOBJ) -L. -lSAI $(LIBS) | |
| depends: | |
| $(RM) $(DEPENDS) | |
| $(MAKE) $(DEPENDS) | |
| $(DEPENDS): | |
| $(CXX) -MM $(CXXFLAGS) $(ALLSRCS) > $(DEPENDS) | |
| $(BUILDDIR): | |
| @mkdir -p $(BUILDDIR) | |
| clean: | |
| $(RM) $(PROG) *.o *.a *~ *.bak */*~ */*.bak | |
| distclean: | |
| $(RM) -r $(BUILDDIR) $(PROG) *.o *.a *~ *.bak */*~ */*.bak $(DEPENDS) | |
| VERSION = $(shell sed -ne 2p ncm_version) | |
| install: $(PROG) $(DIRS) | |
| $(INSTALL) $(PROG) $(INSTALLDIR)/$(PROG).$(VERSION) | |
| DIRS: $(INSTALLDIR) | |
| @mkdir -p $(INSTALLDIR) | |
| link: | |
| cd $(INSTALLDIR) && $(LN) -f $(PROG).$(VERSION) $(PROG) | |
| ls -lFao $(INSTALLDIR) | |
| include $(DEPENDS) | |
| # DO NOT DELETE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment