conditional rules in t3m?

Is it possible to have a macro like:
#IFDEF TADS_INCLUDE_NET

#ELSE

#ENDIF
inside the t3m file?

This sounds suspiciously more like cmake than gnu-make, but I think you get the idea:)

What I’d like to be able to do is allow me to pass -WEB=TRUE or something like that when compiling to switch between web and non-web compilation. I realize I can make two separate makefiles, but this would be nice if it is available. The documentation for these files online seems fairly light (at least what I found) on the details.

This is a thing I would love to have too.

For now I do it by wrapping the t3make system inside my own Makefile and doing a thing like the snippet below, putting the list of args that are about my source code into one file, and the list of args that are about the difference between text and gui builds in other files. Then I concatenate them together in the Makefile rule with something like the following:

textbuild:
        cat text_t3m.txt sourcenames.txt > mybuild.t3m
        $(FROB) $(TEXT_BUILDFLAGS) mybuild.t3m
webbuild:
        cat webUI_t3m.txt sourcenames.txt > mybuild.t3m
        $(FROB) $(WEBUI_BUILDFLAGS) mybuild.t3m

(I have a lot more that the make file does than just that so that’s a simplified version just to get the idea across).

Another rule I use, if you’re interested in seeing it, is one for “make wrun” (meaning “web run”) which runs frob in its webserver mode, greps out the URL from its output, and then tells the $(BROWSER_APP) of your choice to open a new tab and point it at that URL.
Most of the rules I have are generic Unix except that last one which is Mac specific, because it uses the Mac-specific “open something in an App” command (“man 1 open” to see how it works) because Firefox’s commandline option that does the same thing is, for some reason, not enabled on the Mac build of Firefox.

Yeah, I tried to do that, but I couldn’t find a way to reliably get the PID in a context that allowed me to pass it on to wait so that I could just use control-C to kill the server.

start_web: $(PROJECT).t3
frob -i plain -k utf8 -N 44 $(PROJECT).t3 #>& webui.output&
#PID=!$
#sleep 1
#echo “ID $(PID)”
#open /Applications/Google\ Chrome.app cat webui.output | cut -c 14-
#wait $(PID)

I would love to see how you managed.

Ah… technically I was a bit sloppy and didn’t actually quit frob with ctrl-C. I just ctrl-C’ed the ‘tail -f’ command that was showing its output.

What I actually do is at the start of the make rule I kill all existing previous instances of frob before running a new one.

So technically I’m leaving one frob uselessly running the whole time between executions and it doesn’t got away until I try to run again. I stopped it from making more and more frobs each time I run, but I still do have one wastefully running.

Maybe adding -p option would help? Frob automatically shuts down about two minutes after last client has gone away. But it waits for a key press before it finally exits.

Tomasb, that is great! It looks like either will go away eventually, but I think -p does make it go away sooner.

I hadn’t even thought about killing any previous instances…doh!

Here is the final rule, in case anyone wants to steal it. I’m using && so that if something goes wrong with the load and frob returns non-zero, then you don’t get the browser launched. I do like your moving the browser to a variable, friltsar. Will probably steal that:)

(frob -p -i plain -k utf8 -N 44 $(PROJECT).t3 >& webui.output&) && sleep 1 && open /Applications/Google\ Chrome.app cat webui.output | cut -c 14-

For killing all frob instances, you can just use the command:

killall frob

Hmm. That seems rather unreliable and risky using “cut” to ASSUME you will always have the URL starting exactly after character 14 of frob’s output. I used a ‘sed’ command to cut wherever the colon is, but other than that it’s exactly what you did.

Ah! Yeah, that’s true. I cheated and counted how many characters were in the first part.