Commands using make (13)

  • Force make command to create as many compile processes as specified (4 in the example), so that each one goes into one core or CPU and compilation happens in parallel. This reduces the time required to compile a program by up to a half in the case of CPUs with 2 cores, one fourth in the case of quad cores... and so on.


    16
    make -j 4
    kovan · 2009-08-05 22:50:57 12
  • this oneliner uses make and it's jobserver for parallel execution of your script. The '-j' flag for make defines number of subprocesses to launch, '-f' tells make use stdin instead of Makefile. Also make have neat flag '-l', which "Specifies that no new jobs (commands) should be started if there are others jobs running and the load is at least load (a floating-point number)." Also you can use plain Makefile, for better readability: targets = $(subst .png,.jpg,$(wildcard *.png)) (targets): echo convert $(subst .jpg,.png,$@) $@ all : $(targets)


    5
    echo -n 'targets = $(subst .png,.jpg,$(wildcard *.png))\n$(targets):\n convert $(subst .jpg,.png,$@) $@ \nall : $(targets)' | make -j 4 -f - all
    mechmind · 2010-07-15 07:19:17 7
  • This would allow reference of $(VAR) (if defined) with the value 'foobar' within the Makefile.


    1
    make [target] VAR=foobar
    cifr · 2009-10-12 09:42:30 3
  • Say your dependencies specified in your Makefile (or dates on your source files) is causing 'make' to skip some source-files (that it should not) or on the other other end, if it is causing make to always build some source-files regardless of dates of target, then above command is handy to find out what 'make' thinks of your date v/s target date-wise or what dependencies are in make's view-point. The egrep part removes the extra noise, that you might want to avoid. Show Sample Output


    1
    make -d | egrep --color -i '(considering|older|newer|remake)'
    b_t · 2011-06-03 01:55:08 53
  • on a dpkg managed system this PATTERN will help you generate .deb files from source AND remove all the dev libs you had to install. i hate cluttering up my machine with rouge packages and headers. it would be pretty darn easy on rpm systems as well. i just dont have a rpm managed system to test on right now. NOTE, you sharp ones will notice that it uninstalls the deb you just made! yeah, but the deb is still there to do with it what you want, like re install it. or you can just grep -v after the diff


    0
    dpkg-query -l > 1.lst; sudo apt-get install -y build-essential; ./configure; make; sudo checkinstall -D make install; dpkg-query --list > 2.lst; diff 1.lst 2.lst | grep '^>' | awk '{print $3}' | xargs sudo apt-get remove -y --purge
    danlangford · 2010-06-16 22:06:07 4

  • 0
    cd /usr/src ; wget http://www.rarlab.com/rar/unrarsrc-4.0.2.tar.gz ; tar xvfz unrarsrc-4.0.2.tar.gz ; cd unrar ; ln -s makefile.unix Makefile ; make clean ; make ; make install
    yababay · 2010-12-09 10:35:28 6
  • Join all sequentially named files in the directory. Use this for files split by utilities like hjsplit and similar. This command does not do/perform _any_ sanity checks before acting, except that it won't run unless there is a file that matches "*.001". - The outfile should not already exist. - There should be more than one file. (*.002 should exist as well as *.001) - The file-count should match the number in the name of the last file in the series. - None of the files should be empty. - All files should be the same size, except for the last, which should usually be smaller, but never larger than the rest. A safer altenative can be found here: http://pastebin.com/KSS0zU2F


    0
    x=(*.001); cat "${x%.001}."* > "${x%.001}" #unsafe; does not check that all the parts are there, or that the file-sizes make sense!
    Jessehz · 2011-08-24 04:10:20 3
  • Install Ksuperkey one command in Kubuntu. You must manually add ksuperkey to autostart in System Settings KDE.


    0
    sudo apt-get install git gcc make libx11-dev libxtst-dev pkg-config -y && git clone https://github.com/hanschen/ksuperkey.git && cd ksuperkey && make && sudo mv ksuperkey /usr/bin/ksuperkey && cd ~ && rm -rf ksuperkey
    FadeMind · 2013-04-17 07:12:46 6

  • 0
    make --print-data-base --dry-run | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
    grapsus · 2013-10-07 12:39:25 6

  • 0
    make your terminal interactive and fun
    andreisid · 2016-03-23 09:01:37 11
  • Will prepend date and time in the following format: dd-mm-yyyy@hh:mm:ss (24hours format) and redirect it to make.out file Show Sample Output


    0
    make -j 2>&1 | while IFS= read -r line; do echo "$(date +"%d-%m-%Y@%T") $line"; done > make.out
    redowk · 2017-03-06 18:14:51 21

  • -4
    Place a filename at the beginning of the line to make it easier to edit the search at the end of the command.
    iveney · 2009-02-07 12:03:19 12
  • Just copy and paste the code in your terminal. Note : sudo apt-get for debian versions , change as per your requirement . Source : www.h3manth.com


    -6
    sudo wget -c "http://nmap.org/dist/nmap-5.00.tar.bz2" && bzip2 -cd nmap-5.00.tar.bz2 | tar xvf - && cd nmap-5.00 && ./configure && make && sudo make install
    hemanth · 2009-07-26 11:36:53 7

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Monitoring file handles used by a particular process
-r : repeat mode

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Show complete URL in netstat output
The -W switch of netstat makes it print complete URL of the connections, which otherwise by default is truncated to fit its default column size. Now to compensate for irregular column sizes, pipe the output to column (-t switch of column prints in tabular form). The only downside to this part is that the very first row, the header, goes pear shape.

swap stdout and stderr
Possible use, to filter something in stderr: (/usr/bin/$COMMAND $PARAM 3>&1 1>&2 2>&3 | grep -v $uninteresting_error ) 3>&1 1>&2 2>&3

Display the definition of a shell function
Display the code of a previously defined shell function.

Remove a range of lines from a file

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Benchmark SQL Query
Benchmark a SQL query against MySQL Server. The example runs the query 10 times, and you get the average runtime in the output. To ensure that the query does not get cached, use `RESET QUERY CACHE;` on top in the query file.

Connect to remote machine with other enconding charset

raw MySQL output to use in pipes
-N removes header -s removes separator chars -r raw output After using these options, the MySQL ouptut can be used with pipes very easily


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: