Sponsored Content
Operating Systems Linux how to enable #ifdef macro in the command line of make? Post 302154323 by princelinux on Saturday 29th of December 2007 03:20:52 AM
Old 12-29-2007
how to enable #ifdef macro in the command line of make?

[Keyword] Linux, C++, make, macro

In source code, we used some #ifdef macros. How can I enable #ifdef macro in the command line of "make" (NOTE: I do NOT want to change source code or makefile to define that macro from time to time).

e.g. test.cpp:
...
#ifdef TEST1
// code segment for test1
...
#endif
...
#ifdef TEST2
// code segment for test2
...
#endif
....

Question: How can I enable either macro via command line of make?
e.g. make ????? -> enable TEST1
make ????? -> enable TEST2

Thanks in advance!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Surrounding a chunk of code by #ifdef and #endif

Hello the great gurus :) I'm quite new to this, so perhaps I'm asking a simple and trivial question (which is good, because you'll answer for sure :)))) Anyway. I have an amount of *.c files (about 100), and what I want to do, is to surround a specific function call with #ifdef and #endif. ... (6 Replies)
Discussion started by: xxxaxa
6 Replies

2. Programming

Make-question - redefine a macro, using another macro..?

I think there is no problem to use any macro in a new macro definishion, but I have a problem with that. I can not understand why? I have a *.mak file that inludes file with many definitions and rules. ############################################## include dstndflt.mak ... One of the... (2 Replies)
Discussion started by: alex_5161
2 Replies

3. Homework & Coursework Questions

I need to make a script that has 4 command line arguments to function properly.

I have no idea what the following means. The teacher is too advanced for me to understand fully. We literally went from running a few commands over the last few months to starting shell scripting. I am not a programmer, I am more hardware oriented. I wish I knew what this question was asking... (3 Replies)
Discussion started by: Wookard
3 Replies

4. Shell Programming and Scripting

How to make command line interactive?

I have a file with stats for different month, I use the cat and grep combination to search for different month. cat <file> | grep "April" cat <file> | grep "May" cat <file> | grep "June" etc. How do you make this command interactive. So that I can give the values for the search. Thanks... (7 Replies)
Discussion started by: purelltab
7 Replies

5. Shell Programming and Scripting

Homework: Make a one-line Unix command - using pipe(s)

Task A: Make a one-line Unix command - using pipe(s) - to display the number of files in your home directory including the hidden files that begin with '.' Task B:Make a one-line Unix command - using pipe(s) - to display the number of unique zip codes in famous.dat (hint: use -u on sort) Task... (1 Reply)
Discussion started by: wises
1 Replies

6. Shell Programming and Scripting

How to use ifdef for bash variables in csh environment?

Hi Guys, I have a a bash script and i am exporting a variable in it. I am calling a csh script from this bash script. The variable "ABC" will be visible in csh script. ks.bash export ABC = abc ./kp.csh ab.csh echo $ABC setenv ABC =cde (i want to assign this value to ABC only if... (4 Replies)
Discussion started by: vdhingra123
4 Replies

7. UNIX for Dummies Questions & Answers

Why cant I use enable command

Why can I not use the enable command? *sofiazoe* (2 Replies)
Discussion started by: anglenasalt
2 Replies

8. Programming

Make a file accept only two arguments from the command line

DELETED (2 Replies)
Discussion started by: ProgMan2015
2 Replies

9. Homework & Coursework Questions

Make a file accept only two arguments from the command line

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1) The script is executed in the Korn shell. 2) Name the shell script file is asg6s. 3) The asg6s file is... (7 Replies)
Discussion started by: ProgMan2015
7 Replies

10. UNIX for Advanced & Expert Users

Enable 'make uninstall' hook?

Heyas I'm currently trying to make 'make uninstall' work properly, as it doesnt remove empty directories. To do so, i've applied: uninstall-hook: if test -d $docdir; then rmdir $docdir; fi As stated (example) in automake - 'make uninstall': Howto remove empty directories - Stack... (2 Replies)
Discussion started by: sea
2 Replies
SHAPE_BUILD(1)						      General Commands Manual						    SHAPE_BUILD(1)

NAME
shape_build - shapeTools RMS system building and installation SYNOPSIS
shape [all][VERSIONS=<rule>] [variants] [macro settings] shape install[VERSIONS=<rule>] [INSTALLBASE=<path>] [variants] [macro settings] shape clean[<macro settings>] shape cleancache [<macro settings>] make [all][<macro settings>] make install[INSTALLBASE=<path>] [<macro settings>] make clean[<macro settings>] DESCRIPTION
Shape all, or just shape (as all is the default target), builds the current system node. It performs all necessary actions to derive the main target ($(TARGET) in the Makefile) from the node's source components. Shape all also builds all subsystems of the current node. Before triggering any build action itself, if recursively calls shape for each subsystem. Version selection is driven by the rule given as value to the VERSIONS macro, default is most_recent. The given version selection rule on the command line, if any, is inherited to the recursive calls. Shape install installs the build results of the current node in the appropriate locations. Things to be installed are usually binaries and manuals. The target installtargets in the Makefile lists all these things as its dependents. Shape install updates all build results in the same way as shape all does, before installing them. Shape install invokes all subsystems of the current node in the installation procedure by recursively calling shape install for each of them. This is done, before it performs any build or install actions itself. The appropri- ate versions are selected according to the given version selection rule named in the VERSIONS macro. The default rule for shape install is recent_release selecting the most recent release or prerelease (whichever is newer). The macro INSTALLBASE defines the installation base directory, an absolute pathname pointing to the root of a directory tree, where the build results are to be copied to. Check the Makefile for the default setting of INSTALLBASE and the installation directories defined as relative pathnames starting from the installation base directory. Values of the VERSION and the INSTALLBASE macro set on the command line are inherited to all recursive calls. Shape clean removes all derived objects currently established as UNIX files. These are the files listed in the OBJECTS macro in the Make- file, the derived target ($(TARGET)), and the target aliases ($(ALIASES)). The derived objects, established as UNIX files are those being produced from their source or reinstalled from the derived object cache during the last system build. Shape cleancache cleans up the derived object cache, will say, it removes all objects stored there. All names listed as dependents of the .BPOOL special macro in the Shapefile are candidates to be cached. When multiple (different) versions of derived objects with the same name arise, the older ones are stored to the derived object cache. Shape cleancache in conjunction with shape clean removes all derived (automatically reproducible) objects. The two cleanup actions are not called recursively. They apply only to the current node. The build and cleanup actions (all, install and clean) of the shape RMS can be performed by make(1) and by shape(1). The main difference is, that shape is capable of setting up the appropriate source context according to a given version selection rule, while make only regards the regular UNIX files. Make will fail if not every component of the system has a checked out busy version. The intention for maintaining Makefiles suitable for complete system builds aims at system building and installation from a source distribution rather than from the development area. Source distributions are system copies taken from one of the release trees (partial release area or release area). See shape_RMS(1) for details. Make all, make install and make clean behave similar to their shape counterparts. The difference is, that they expect a complete system source context to be set up as UNIX files (see above). Each macro definition in the Make- or Shapefile may be redefined from the command line. Most of the shape RMS standard macro definitions are inherited to recursive calls of make or shape. Check the shape_tmpl(7) manual page for a list of the standard macros. INCONVENIENCES
For technical reasons, each make call recursively invokes make on the same level before performing any actions. This unfortunately restricts the efficacy of command line options. E.g. there is no chance to work with the -f (alternate name for the Makefile) option and the redefinition of macros is restricted to inherited ones. This restriction does not apply to shape calls. FILES
Makefile Shapefile SEE ALSO
shape_stdrul(7), shape_tmpl(7) 1.6.119 SHAPE_BUILD(1)
All times are GMT -4. The time now is 10:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy