ifeq ($(OS),Windows_NT) OSCLASS = windows OSNAME=windows else OSCLASS = unix UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) OSNAME = linux endif ifeq ($(UNAME_S),Darwin) OSNAME = osx endif endifYou can then do switches based upon the compiling OS. The biggest one was that I needed to output to a file. The problem with files that would write to both windows and unix is that the shell commands are different, so I need to address the differences in commands.
ifeq ($(OSCLASS),unix) FIXDIR = $1 COMMANDCAT = cat else FIXDIR = $(subst /,\,$1) COMMANDCAT = type endifWindows uses "type", whereas unix uses "cat". I then also fix the \ issue to go from the the unix / to the windows \ with the FIXDIR command. When I type "make test", the following will output the contents of info/chunk2.txt and append it to installer/test.inf.
test: $(COMMANDCAT) $(call FIXDIR,info/chunk2.txt >> installer/test.inf)In unix, you will get: cat info/chunk2.txt >> installer/test.inf
In Windows, you get: type info\chunk2.txt >> installer\test.inf
No comments:
Post a Comment