From 54d64411ab12bd180e46600d23acede8f74bcacf Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 23 Sep 2012 12:53:25 -0400 Subject: [PATCH] replace Makefile with a premake script for generating make/ide files --- Makefile | 154 ------------------------------------------- generate_makefile.sh | 3 + generate_vs2010.bat | 8 +++ premake.lua | 63 ++++++++++++++++++ 4 files changed, 74 insertions(+), 154 deletions(-) delete mode 100644 Makefile create mode 100755 generate_makefile.sh create mode 100644 generate_vs2010.bat create mode 100644 premake.lua diff --git a/Makefile b/Makefile deleted file mode 100644 index c7a6db3..0000000 --- a/Makefile +++ /dev/null @@ -1,154 +0,0 @@ -# this Makefile is based on the ones from devkitPro -# TODO: probably should simplify it a bunch (mainly the rules at the bottom) - -TARGET := md2tomesh - - - -#------------------------------------------------------------------------------- -# detect build configuration -#------------------------------------------------------------------------------- -ifndef ("CFG") -CFG=Debug -endif - -ifeq ("$(CFG)","Debug") -BUILD := Debug -endif -ifeq ("$(CFG)","Release") -BUILD := Release -endif -ifeq ("$(BUILD)", "") -$(error invalid configuration specified via CFG argument) -endif - -$(info $(CFG) configuration selected) - - - -#------------------------------------------------------------------------------- -# set up platform specifics -#------------------------------------------------------------------------------- -UNAME := $(shell uname) - -#------------------------------------------------------------------------------- -# default windows libraries and options -PLATFORM := win32 -PLATFORM_LD_FLAGS := -static-libgcc -static-libstdc++ -#------------------------------------------------------------------------------- -ifeq ($(UNAME), Linux) -PLATFORM := linux -PLATFORM_LD_FLAGS := -endif -#------------------------------------------------------------------------------- -ifeq ($(UNAME), Darwin) -PLATFORM := osx -PLATFORM_LD_FLAGS := -endif -#------------------------------------------------------------------------------- - - -#------------------------------------------------------------------------------- -ifeq ("$(BUILD)","Debug") -DEFINES := -DDEBUG -DDEBUG_ASSERT_BREAK -CFLAGS := $(DEFINES) -g -Wall -CXXFLAGS := $(CFLAGS) -LDFLAGS := $(PLATFORM_LD_FLAGS) -LIBS := -g -endif -#------------------------------------------------------------------------------- -ifeq ("$(BUILD)","Release") -DEFINES := -CFLAGS := $(DEFINES) -O2 -Wall -CXXFLAGS := $(CFLAGS) -LDFLAGS := -O2 $(PLATFORM_LD_FLAGS) -LIBS := -endif -#------------------------------------------------------------------------------- - - - -#------------------------------------------------------------------------------- -# find sources, setup commands -#------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#------------------------------------------------------------------------------- - -SOURCES := ${shell find ./src -type d} -export OUTPUT := $(TARGET) -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) - -export CXX := g++ -export CC := g++ -export LD := g++ -export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -.PHONY: $(BUILD) clean - -#------------------------------------------------------------------------------- -$(BUILD): - $(info building ...) - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#------------------------------------------------------------------------------- -clean: - $(info clean ...) - @rm -fr $(BUILD) - @rm $(OUTPUT) - -#------------------------------------------------------------------------------- -else - - - -#------------------------------------------------------------------------------- -# main targets -#------------------------------------------------------------------------------- -$(OUTPUT): $(OFILES) - $(info linking $(notdir $@)) - $(LD) -o $@ $(LDFLAGS) $(OFILES) $(LIBS) - cp $(OUTPUT) ../ - - - - -#------------------------------------------------------------------------------- -# build rules by filetype -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -%.a: -#------------------------------------------------------------------------------- - $(info $(notdir $<)) - @rm -f $@ - @$(AR) -rc $@ $^ - -#------------------------------------------------------------------------------- -%.o: %.cpp - $(info $(notdir $<)) - @$(CXX) -c $< -o $@ $(CXXFLAGS) - -#------------------------------------------------------------------------------- -%.o: %.c - $(info $(notdir $<)) - @$(CC) -c $< -o $@ $(CFLAGS) - -#------------------------------------------------------------------------------- -%.o: %.s - $(info $(notdir $<)) - @$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ - -#------------------------------------------------------------------------------- -%.o: %.S - @echo $(notdir $<) - @$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ - -#------------------------------------------------------------------------------- -endif -#------------------------------------------------------------------------------- - diff --git a/generate_makefile.sh b/generate_makefile.sh new file mode 100755 index 0000000..33d7a29 --- /dev/null +++ b/generate_makefile.sh @@ -0,0 +1,3 @@ +#!/bin/sh +type premake4 >/dev/null 2>&1 || { echo >&2 "'premake4' not found in your path."; exit 1; } +premake4 --file=premake.lua gmake diff --git a/generate_vs2010.bat b/generate_vs2010.bat new file mode 100644 index 0000000..9538990 --- /dev/null +++ b/generate_vs2010.bat @@ -0,0 +1,8 @@ +@echo off +for %%X in (premake4.exe) do (set FOUND=%%~$PATH:X) +if not defined FOUND ( +echo 'premake4' not found in your path. +exit /b +) + +premake4 --file=premake.lua vs2010 diff --git a/premake.lua b/premake.lua new file mode 100644 index 0000000..2426acb --- /dev/null +++ b/premake.lua @@ -0,0 +1,63 @@ + +BUILD_DIR = "build" + +if _ACTION == "clean" then + os.rmdir(BUILD_DIR) +end + +solution "Md2ToMesh" + configurations { "Debug", "Release" } + location (BUILD_DIR .. "/" .. _ACTION) + +project "Md2ToMesh" + kind "ConsoleApp" + language "C++" + location (BUILD_DIR .. "/" .. _ACTION) + files { + "./src/**.c*", + "./src/**.h", + } + debugdir "." + + ---- PLATFORM SPECIFICS ---------------------------------------------------- + configuration "vs*" + flags { + "NoPCH", + "NoMinimalRebuild" + } + buildoptions { "/MP" } + defines { + "_CRT_SECURE_NO_WARNINGS", + "_CRT_NONSTDC_NO_WARNINGS" + } + + configuration "gmake" + kind "ConsoleApp" + buildoptions { "-Wall" } + + configuration { "windows", "gmake" } + kind "ConsoleApp" + defines { + "_GNU_SOURCE=1", + } + links { + "mingw32", + } + linkoptions { + "-static-libgcc", + "-static-libstdc++", + } + ---------------------------------------------------------------------------- + + configuration "Debug" + defines { + "DEBUG", + "DEBUG_ASSERT_BREAK", + } + flags { "Symbols" } + + configuration "Release" + defines { + "NDEBUG", + } + flags { "Optimize" }