## Humdrum extras programs makefile for linux on Intel computers. ## ## Programmer: Craig Stuart Sapp ## Creation Date: Sun Apr 3 15:34:28 PDT 2005 ## Last Modified: Wed Mar 9 12:46:27 PST 2016 ## Filename: ...humextra/Makefile.programs ## ## Description: This Makefile creates the Humdrum Extras library ## lib/libhumextra.a for linux, using gcc 2.7.2.1 or higher ## Also, gives basic guidelines of how to compile for Windows ## using MinGW. ## ## To run this makefile, type (without quotes) "make -f Makefile.programs" ## (or "gmake -f Makefile.programs" on FreeBSD computers), although it ## is intended to be used the file "Makefile" which runs this makefile ## with the command "make programs". Note that you have to first ## create the library file with the makefile "Makefile.library". ## ## Without arguments, this makefile will compile all programs. ## If you give a program name as an argument, it will compile ## just that program. E.g.: "make -f Makefile.programs blank" or used ## in conjunction with "Makefile", type "make blank", which will ## compile the "blank" program and place it in the ./bin directory. ## ########################################################################### # # # Operating System OSTYPEs available in the humextra library # # compilation: but probably not used in humextra: # # # # HPUX = Hewlett-Packard Unix Workstations. # # IRIX = SGI computers with IRIX OS. # # LINUX = Linux running on intel computers # # NEXTI = NeXT OS on Intel Hardware # # NEXTM = NeXT OS on Motorola Hardware # # SUN = Sun SPARCstations # # VISUAL = Windows 95/NT using Microsoft Visual C++ 6.0 # # OSXPC = Apple Macintosh OS 10.x, Intel CPU # # # # Look at the sigConfiguration.h file for various things which need # # to be defined specifically for each OS. Only one of these defines # # can be defined at a time. # # # ########################################################################### # # You can set the OSTYPE variable by uncommenting one of the lines below; # otherwise, it will be set automatically in the next section of the # Makefile if the configuration should be OSXPC or LINUX. For example, #OSTYPE = LINUX #OSTYPE = OSXPC ARCH = # Set the environmental variable $MACOSX_DEPLOYMENT_TARGET to # "10.4" in Apple OS X to compile for OS X 10.4 and later (for example, # you can compile for OS X 10.4 computers even if you are using a 10.6 # computer). ENV = # if OSTYPE is not defined, then this if statement will be run: ifeq ($(origin OSTYPE), undefined) ifeq ($(shell uname),Darwin) OSTYPE = OSXPC # Use the following to compile for a particular version of OS X: # ENV = MACOSX_DEPLOYMENT_TARGET=10.6 # Use the following to compile for 32-bit architecture on 64-bit comps: #ARCH = -m32 -arch i386 else OSTYPE = LINUX # use the following to compile for 32-bit architecture on 64-bit comps: # (you will need 32-bit libraries in order to do this) # ARCH = -m32 endif endif # Next if statement needed for some versions of make which already set OSTYPE: ifeq ($(OSTYPE),linux) OSTYPE = LINUX # use the following to compile for 32-bit architecture on 64-bit comps: # (you will need 32-bit libraries in order to do this) # ARCH = -m32 endif # Cygwin (and MinGW?) adds the string ".exe" to the end of compiled programs. # so select EXTEN = .exe when compiling in cygwin EXTEN = ifeq ($(shell uname),CYGWIN_NT-5.1) EXTEN = .exe endif ########################################################################### # # # The OSSUBTYPE is for determining which type of sound drivers are being # # used in linux. This variable is only needed when compiling interactive # # MIDI programs. Most humextra programs do not need this variable. # # There are three possibilities: # # # # OSSUBTYPE = ALSA : ALSA 1.0 interface (http://www.alsa-project.org)# # OSSUBTYPE = OSS : OSS interface (http://www.4front-tech.com) # # OSSUBTYPE = : use this for OS X since there is only CoreMIDI # # # # Two additional options are available for older systems: # # OSSUBTYPE = ALSA09 : ALSA 0.9 interface (http://www.alsa-project.org)# # OSSUBTYPE = ALSA05 : ALSA 0.5 interface (http://www.alsa-project.org)# # # # Note: The Improv library accesses the internal/external MIDI devices # # in OSS, but only the external MIDI devices in ALSA. OSS can be # # emulated in ALSA 0.9 and higher, but seems to be broken in ALSA 1.0. # # # # Choose one of the following OSSUBTYPE defines: # # # #OSSUBTYPE = ALSA #OSSUBTYPE = OSS #OSSUBTYPE = # If OSSUBTYPE is not set manually above, then automatically determine # what the value should be (only works for LINUX and OSXPC). ifeq ($(origin OSSUBTYPE), undefined) ifeq ($(OSTYPE),OSXPC) OSSUBTYPE = endif ifeq ($(OSTYPE),LINUX) ifneq ($(wildcard /proc/asound/version),) OSSUBTYPE = ALSA else OSSUBTYPE = OSS endif endif endif ########################################################################### # # # Beginning of user-modifiable configuration variables # # # SRCDIR = src-programs INCDIR = include OBJDIR = obj LIBDIR = lib LIBFILE = humextra TARGDIR = bin # LANG=C: Nuts to the GCC error beautification committee. COMPILER = LANG=C $(ENV) g++ $(ARCH) # MinGW compiling setup (used to compile for Microsoft Windows but actual # compiling can be done in Linux). You have to install MinGW and these # variables will probably have to be changed to the correct paths: #COMPILER = /opt/xmingw/bin/i386-mingw32msvc-g++ #OBJDIR = obj-win #TARGDIR = bin-win #LIBDIR = lib-win #POSTFLAGS = -Wl,--export-all-symbols -Wl,--enable-auto-import \ # -Wl,--no-whole-archive -lmingw32 -L$(LIBDIR) -l$(LIBFILE) DEFINES = $(addprefix -D,$(OSTYPE)) DEFINES += $(addprefix -D,$(OSSUBTYPE)) PREFLAGS = -O3 -Wall -I$(INCDIR) $(DEFINES) # Options class uses C++11 standard, so need to compile all code using C++11: PREFLAGS += -std=c++11 # Add -static flag to compile without dynamics libraries for better portability: # (-static flag doesn't work well with gethostbyname() used in Humdrum parser) #PREFLAGS += -static POSTFLAGS ?= -L$(LIBDIR) -l$(LIBFILE) ########################################################################### ## ## Linking to external libraries: ## There are four external libraries which are used to compile the ## humextra programs: ## (1) PCRE (http://www.pcre.org) ## This is used for working with regular expressions. May be ## fased out when GCC version 5+ is ubiquitous on linux computers. ## GCC 5+ implments C++11 standard which includes regular expressions ## for C++ (however, they are based on JavaScript regular expressions ## rather than PERL, so we will see). ## (2) CenterpointXML by Guenter Obiltschnig ## Now orphaned C++ library for parsing XML file. Will be updated ## to pugixml (http://www.pugixml.org) in the future. ## (3) midifile (http://midifile.sapp.org) ## Used to parse or create Standard MIDI Files. ## (4) improv (http://improv.sapp.org) ## Used for cross-platform real-time MIDI playback. ## # The following setup is for PERL-Compatible Regular Expression library # linking (for themax2 in particular, but also in many other humextra # programs as well). Therefore it is used when linking all programs. ifneq ($(wildcard external/pcre-8.35),) PREFLAGS += -Iexternal/pcre-8.35 POSTFLAGS += -lpcre PCRE := yes endif # The following setup is for compiling XML parsing code # which uses the CenterPoint XML classes: ifneq ($(wildcard external/centerpoint),) XML_PREFLAGS = -Iexternal/centerpoint/include XML_POSTFLAGS = -lcslxml XML := yes endif # The following setup is for MIDI files parsing: ifneq ($(wildcard external/midifile),) MIDIFILE_PREFLAGS = -Iexternal/midifile/include MIDIFILE_POSTFLAGS = -Lexternal/midifile/lib -lmidifile MIDIFILE := yes endif # For compiling programs with interactive MIDI (such as humplay), you # first need to compile the improv library which can be downloaded # from http://improv.sapp.org (Makefile.library tries to do this). ifneq ($(wildcard external/improv),) IMPROV_PREFLAGS = -Iexternal/improv/include IMPROV_POSTFLAGS = -Lexternal/improv/lib -limprov IMPROV_PREFLAGS += -Iexternal/midifile/include IMPROV_POSTFLAGS += -Lexternal/midifile/lib -l midifile IMPROV := yes # Thread library needed for MIDI input programs in Linux: # Probably also need in OS X? ifeq ($(OSTYPE),LINUX) IMPROV_POSTFLAGS += -L/usr/lib -lpthread endif endif ################################### # # Interactive MIDI program compiling setup # # extra setup for compiling interactive MIDI programs: ifneq ($(origin IMPROV),undefined) # On Apple OS X computers, include MIDI related libraries: ifeq ($(OSTYPE),OSXPC) IMPROV_POSTFLAGS += -framework CoreMIDI -framework CoreServices IMPROV_POSTFLAGS += -framework AudioUnit -framework AudioToolbox endif # On Linux computers, include MIDI related libraries: ifeq ($(OSTYPE),LINUX) # include pthread library for MIDI input parsing: # Add the ALSA library interface, if using ALSA: ifeq ($(OSSUBTYPE),ALSA) IMPROV_PREFLAGS += -I/usr/include/alsa IMPROV_POSTFLAGS += -lasound endif endif endif # # # End of user-modifiable variables. # # # ########################################################################### # setting up the directory paths to search for program source code vpath %.cpp $(SRCDIR) # generating a list of the programs to compile with "make all" PROGS1=$(notdir $(patsubst %.cpp,%,$(wildcard $(SRCDIR)/*.cpp))) PROGS=$(PROGS1) # Prepare a list of scripts to link into bin directory. SCRIPTS_PERL=$(wildcard scripts/perl/*) SCRIPTS=$(SCRIPTS_PERL) # Targets which don't actually refer to files .PHONY : bin scripts src-programs src-library include obj bin-win obj-win ########################################################################### # # # # examples: all all: bin scripts $(addprefix $(TARGDIR)/,$(PROGS)) @echo Finished compiling all programs. info: @echo "Programs to compile: $(PROGS)" | fmt bin: ifeq ($(wildcard $(TARGDIR)),) -mkdir -p $(TARGDIR) endif # link all scripts into the bin directory scripts: -for i in $(SCRIPTS); do ln -s ../$$i bin/`basename $$i`; done ########################################################################### ## ## Certain programs require different external libraries, so give the ## required external library dependencies by program here. All programs ## are preseumed to require PCRE, so that is added to the default ## PREFLAGS and POSTFLAGS variable ## xml2hum: PREFLAGS += $(XML_PREFLAGS) xml2hum: POSTFLAGS += $(XML_POSTFLAGS) $(TARGDIR)/xml2hum: PREFLAGS += $(XML_PREFLAGS) $(TARGDIR)/xml2hum: POSTFLAGS += $(XML_POSTFLAGS) hum2mid: PREFLAGS += $(MIDIFILE_PREFLAGS) hum2mid: POSTFLAGS += $(MIDIFILE_POSTFLAGS) $(TARGDIR)/hum2mid: PREFLAGS += $(MIDIFILE_PREFLAGS) $(TARGDIR)/hum2mid: POSTFLAGS += $(MIDIFILE_POSTFLAGS) mid2hum: PREFLAGS += $(MIDIFILE_PREFLAGS) mid2hum: POSTFLAGS += $(MIDIFILE_POSTFLAGS) $(TARGDIR)/mid2hum: PREFLAGS += $(MIDIFILE_PREFLAGS) $(TARGDIR)/mid2hum: POSTFLAGS += $(MIDIFILE_POSTFLAGS) mkeyscape: PREFLAGS += $(MIDIFILE_PREFLAGS) mkeyscape: POSTFLAGS += $(MIDIFILE_POSTFLAGS) $(TARGDIR)/mkeyscape: PREFLAGS += $(MIDIFILE_PREFLAGS) $(TARGDIR)/mkeyscape: POSTFLAGS += $(MIDIFILE_POSTFLAGS) humplay: PREFLAGS += $(IMPROV_PREFLAGS) $(ALSA_PREFLAGS) humplay: POSTFLAGS += $(IMPROV_POSTFLAGS) $(ALSA_POSTFLAGS) $(TARGDIR)/humplay: PREFLAGS += $(IMPROV_PREFLAGS) $(ALSA_PREFLAGS) $(TARGDIR)/humplay: POSTFLAGS += $(IMPROV_POSTFLAGS) $(ALSA_POSTFLAGS) ########################################################################### # # Defining explicit rules for program sourcefile dependencies: # % : $(notdir %.cpp) @mkdir -p $(TARGDIR) @echo [CC] $@ @$(COMPILER) $(PREFLAGS) -o $(TARGDIR)/$@ $< $(POSTFLAGS) \ && strip $(TARGDIR)/$@$(EXTEN) $(TARGDIR)/% : $(notdir %.cpp) @mkdir -p $(TARGDIR) @echo [CC] $@ @$(COMPILER) $(PREFLAGS) -o $@ $< $(POSTFLAGS) \ && strip $@$(EXTEN) # # # # ###########################################################################