generic.t 7.41 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2 3 4 5
#!
#! This is a tmake template for building Win32 applications or libraries.
#!
#${
    if ( Config("qt") ) {
6 7 8
	if ( !(Project("DEFINES") =~ /QT_NODLL/) &&
	     ((Project("DEFINES") =~ /QT_(?:MAKE)?DLL/) ||
	      ($ENV{"QT_DLL"} && !$ENV{"QT_NODLL"})) ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
9
	    Project('TMAKE_QT_DLL = 1');
10
	    if ( (Project("TARGET") eq "qt") && Project("TMAKE_LIB_FLAG") ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
11 12 13 14 15 16 17 18 19 20 21 22
		Project('CONFIG += dll');
	    }
	}
    }
    if ( Config("dll") || Project("TMAKE_APP_FLAG") ) {
	Project('CONFIG -= staticlib');
	Project('TMAKE_APP_OR_DLL = 1');
    } else {
	Project('CONFIG += staticlib');
    }
    if ( Config("warn_off") ) {
	Project('TMAKE_CFLAGS += $$TMAKE_CFLAGS_WARN_OFF');
23
	Project('TMAKE_CXXFLAGS += $$TMAKE_CXXFLAGS_WARN_OFF');
Dimitri van Heesch's avatar
Dimitri van Heesch committed
24 25
    } elsif ( Config("warn_on") ) {
	Project('TMAKE_CFLAGS += $$TMAKE_CFLAGS_WARN_ON');
26
	Project('TMAKE_CXXFLAGS += $$TMAKE_CXXFLAGS_WARN_ON');
Dimitri van Heesch's avatar
Dimitri van Heesch committed
27 28 29
    }
    if ( Config("debug") ) {
	Project('TMAKE_CFLAGS += $$TMAKE_CFLAGS_DEBUG');
30
	Project('TMAKE_CXXFLAGS += $$TMAKE_CXXFLAGS_DEBUG');
Dimitri van Heesch's avatar
Dimitri van Heesch committed
31 32 33
	Project('TMAKE_LFLAGS += $$TMAKE_LFLAGS_DEBUG');
    } elsif ( Config("release") ) {
	Project('TMAKE_CFLAGS += $$TMAKE_CFLAGS_RELEASE');
34
	Project('TMAKE_CXXFLAGS += $$TMAKE_CXXFLAGS_RELEASE');
Dimitri van Heesch's avatar
Dimitri van Heesch committed
35 36 37 38 39 40
	Project('TMAKE_LFLAGS += $$TMAKE_LFLAGS_RELEASE');
    }
    if ( Config("qt") || Config("opengl") ) {
	Project('CONFIG += windows' );
    }
    if ( Config("qt") ) {
41 42 43 44 45
	Project('CONFIG *= moc');
	AddIncludePath(Project("TMAKE_INCDIR_QT"));
	if ( Config("release") ) {
	    Project('DEFINES += NO_DEBUG');
	}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
46 47 48
	if ( Config("opengl") ) {
	    Project('TMAKE_LIBS *= $$TMAKE_LIBS_QT_OPENGL');
	}
49 50 51
	if ( (Project("TARGET") eq "qt") && Project("TMAKE_LIB_FLAG") ) {
	    if ( Project("TMAKE_QT_DLL") ) {
		Project('DEFINES -= QT_DLL');
Dimitri van Heesch's avatar
Dimitri van Heesch committed
52
		Project('DEFINES *= QT_MAKEDLL');
53
		Project('TMAKE_LFLAGS += $$TMAKE_LFLAGS_QT_DLL');
Dimitri van Heesch's avatar
Dimitri van Heesch committed
54 55
	    }
	} else {
56
	    if ( Project("TMAKE_QT_DLL") ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
57 58 59
		Project('DEFINES *= QT_DLL');
	    }
	    Project('TMAKE_LIBS *= $$TMAKE_LIBS_QT');
60
	    if ( Project("TMAKE_QT_DLL") ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
61 62
		my $qtver =FindHighestLibVersion($ENV{"QTDIR"} . "/lib", "qt");
		Project("TMAKE_LIBS /= s/qt.lib/qt${qtver}.lib/");
63 64 65
		if ( !Config("dll") ) {
		    Project('TMAKE_LIBS *= $$TMAKE_LIBS_QT_DLL');
		}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
	    }
	}
    }
    if ( Config("opengl") ) {
	Project('TMAKE_LIBS *= $$TMAKE_LIBS_OPENGL');
    }
    if ( Config("dll") ) {
	Project('TMAKE_LFLAGS_CONSOLE_ANY = $$TMAKE_LFLAGS_CONSOLE_DLL');
	Project('TMAKE_LFLAGS_WINDOWS_ANY = $$TMAKE_LFLAGS_WINDOWS_DLL');
	if ( Project("TMAKE_LIB_FLAG") ) {
	    my $ver = Project("VERSION");
	    $ver =~ s/\.//g;
	    $project{"TARGET_EXT"} = "${ver}.dll";
	} else {
	    $project{"TARGET_EXT"} = ".dll";
	}
    } else {
	Project('TMAKE_LFLAGS_CONSOLE_ANY = $$TMAKE_LFLAGS_CONSOLE');
	Project('TMAKE_LFLAGS_WINDOWS_ANY = $$TMAKE_LFLAGS_WINDOWS');
85
	if ( Project("TMAKE_APP_FLAG") ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
86 87
	    $project{"TARGET_EXT"} = ".exe";
	} else {
88
	    $project{"TARGET_EXT"} = ".a";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102
	}
    }
    if ( Config("windows") ) {
	if ( Config("console") ) {
	    Project('TMAKE_LFLAGS *= $$TMAKE_LFLAGS_CONSOLE_ANY');
	    Project('TMAKE_LIBS   *= $$TMAKE_LIBS_CONSOLE');
	} else {
	    Project('TMAKE_LFLAGS *= $$TMAKE_LFLAGS_WINDOWS_ANY');
	}
	Project('TMAKE_LIBS   *= $$TMAKE_LIBS_WINDOWS');
    } else {
	Project('TMAKE_LFLAGS *= $$TMAKE_LFLAGS_CONSOLE_ANY');
	Project('TMAKE_LIBS   *= $$TMAKE_LIBS_CONSOLE');
    }
103 104 105
    if ( Config("moc") ) {
	$moc_aware = 1;
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
106 107
    Project('TMAKE_LIBS += $$LIBS');
    Project('TMAKE_FILETAGS = HEADERS SOURCES DEF_FILE RC_FILE TARGET TMAKE_LIBS DESTDIR DLLDESTDIR $$FILETAGS');
108
    foreach ( split(/\s/,Project("TMAKE_FILETAGS")) ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
109 110
	$project{$_} =~ s-[/\\]+-/-g;
    }
111
    if ( Project("DEF_FILE") ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
112 113
	Project('TMAKE_LFLAGS *= $$DEF_FILE');
    }
114 115
    if ( Project("RC_FILE") ) {
	if ( Project("RES_FILE") ) {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
116 117 118 119 120 121 122
	    tmake_error("Both .rc and .res file specified.\n" .
			"Please specify one of them, not both.");
	}
	$project{"RES_FILE"} = $project{"RC_FILE"};
	$project{"RES_FILE"} =~ s/\.rc$/.res/i;
	Project('TARGETDEPS += $$RES_FILE');
    }
123 124 125 126 127 128 129 130 131 132 133 134
    if ( Project("RES_FILE") ) {
	Project('TMAKE_LIBS *= $$RES_FILE');
    }
    $obj_ext  = "o";
    $dir_sep  = "/";
    $gnuwin32 = 1;
    if ( Config("qt") ) {
	$qtdir = $ENV{"QTDIR"};
	$project{"INCPATH"} =~ s/\$\(QTDIR\)/$qtdir/;
	$project{"INCPATH"} =~ s/\\/\//g;
	$project{"TMAKE_LIBS"} =~ s/\$\(QTDIR\)/$qtdir/;
	$project{"TMAKE_LIBS"} =~ s/\\/\//g;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
135 136 137 138 139 140 141 142 143
    }
    StdInit();
    if ( Project("VERSION") ) {
	$project{"VER_MAJ"} = $project{"VERSION"};
	$project{"VER_MAJ"} =~ s/\.\d+$//;
	$project{"VER_MIN"} = $project{"VERSION"};
	$project{"VER_MIN"} =~ s/^\d+\.//;
    }    
    if ( Config("staticlib") ) {
144
	$project{"TARGET"} = $project{"DESTDIR"} . "lib" . $project{"TARGET"}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
145
    } else {
146
	$project{"TARGET"} = $project{"DESTDIR"} . $project{"TARGET"}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
147 148 149 150 151 152 153 154 155 156 157 158
    }
#$}
#!
# Makefile for building #$ Expand("TARGET")
# Generated by tmake at #$ Now();
#     Project: #$ Expand("PROJECT");
#    Template: #$ Expand("TEMPLATE");
#############################################################################

####### Compiler, tools and options

CC	=	#$ Expand("TMAKE_CC");
159
CXX	=	#$ Expand("TMAKE_CXX");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
160
CFLAGS	=	#$ Expand("TMAKE_CFLAGS"); ExpandGlue("DEFINES","-D"," -D","");
161 162
CXXFLAGS=	#$ Expand("TMAKE_CXXFLAGS"); ExpandGlue("DEFINES","-D"," -D","");
INCPATH	=	#$ ExpandPath("INCPATH",'-I',' -I','');
Dimitri van Heesch's avatar
Dimitri van Heesch committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
#$ !Project("TMAKE_APP_OR_DLL") && DisableOutput();
LINK	=	#$ Expand("TMAKE_LINK");
LFLAGS	=	#$ Expand("TMAKE_LFLAGS");
LIBS	=	#$ Expand("TMAKE_LIBS");
#$ !Project("TMAKE_APP_OR_DLL") && EnableOutput();
#$ Project("TMAKE_APP_OR_DLL") && DisableOutput();
AR	=	#$ Expand("TMAKE_AR");
RANLIB	=	#$ Expand("TMAKE_RANLIB");
#$ Project("TMAKE_APP_OR_DLL") && EnableOutput();
MOC	=	#$ Expand("TMAKE_MOC");

ZIP	=	#$ Expand("TMAKE_ZIP");

####### Files

HEADERS =	#$ ExpandList("HEADERS");
SOURCES =	#$ ExpandList("SOURCES");
OBJECTS =	#$ ExpandList("OBJECTS");
SRCMOC	=	#$ ExpandList("SRCMOC");
OBJMOC	=	#$ ExpandList("OBJMOC");
DIST	=	#$ ExpandList("DISTFILES");
TARGET	=	#$ ExpandGlue("TARGET",$project{"DESTDIR"},"",$project{"TARGET_EXT"});

####### Implicit rules

.SUFFIXES: .cpp .cxx .cc .c

.cpp.o:
191
	#$ Expand("TMAKE_RUN_CXX_IMP");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
192 193

.cxx.o:
194
	#$ Expand("TMAKE_RUN_CXX_IMP");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
195 196

.cc.o:
197
	#$ Expand("TMAKE_RUN_CXX_IMP");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
198 199

.c.o:
200
	#$ Expand("TMAKE_RUN_CC_IMP");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241

####### Build rules

all: #$ ExpandGlue("ALL_DEPS",""," "," "); $text .= '$(TARGET)';

$(TARGET): $(OBJECTS) $(OBJMOC) #$ Expand("TARGETDEPS");
#$ Project("TMAKE_APP_OR_DLL") || DisableOutput();
	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
#$ Project("TMAKE_APP_OR_DLL") || EnableOutput();
#$ Project("TMAKE_APP_OR_DLL") && DisableOutput();
	-rm -f $(TARGET)
	$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)
	#$ ExpandGlue("TMAKE_RANLIB","",""," \$(TARGET)");
#$ Project("TMAKE_APP_OR_DLL") && EnableOutput();
#$ (Config("dll") && Project("DLLDESTDIR")) || DisableOutput();
	-cp $(TARGET) #$ Expand("DLLDESTDIR");
#$ (Config("dll") && Project("DLLDESTDIR")) || EnableOutput();
#$ Project('RC_FILE') || DisableOutput();

#$ Substitute("\$\$RES_FILE: \$\$RC_FILE\n\t\$\$TMAKE_RC \$\$RC_FILE");
#$ Project('RC_FILE') || EnableOutput();

moc: $(SRCMOC)

#$ TmakeSelf();

dist:
	#$ Substitute('$(ZIP) $$PROJECT.zip $$PROJECT.pro $(SOURCES) $(HEADERS) $(DIST)');

clean:
	-rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(TARGET)
	#$ ExpandGlue("TMAKE_CLEAN","-rm -f "," ","");
	-rm -f *~ core
	#$ ExpandGlue("CLEAN_FILES","-rm -f "," ","");

####### Compile

#$ BuildObj(Project("OBJECTS"),Project("SOURCES"));
#$ BuildMocObj(Project("OBJMOC"),Project("SRCMOC"));
#$ BuildMocSrc(Project("HEADERS"));
#$ BuildMocSrc(Project("SOURCES"));